<template>
	<view class="content" style="background-color: #f9f3c1; height: 100vh;width: 100%;">
		<view style="padding: 10px;">
			<scroll-view scroll-x class="bg-white nav" style="margin-bottom: 15px;border-radius: 5px;">
				<view class="flex text-center">
					<view style="font-size: large;" class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in tavtext" :key="index" @tap="tabSelect" :data-id="index">
						{{item.text}}
					</view>
				</view>
			</scroll-view>
			<view class="grid col-3 bg-white" style="border-radius: 5px;">
				<view v-if="TabCur == item.xwzt" v-for="(item, index) in gridlist" :index="index" :key="index" @click="link(item)">
					<view class="padding radius text-center shadow-blur">
						<view class="text-lg"><image class="imageIon" webp="true" :src="item.url"  mode="scaleToFill" /></view>
						<view  style="font-size: initial;" class="margin-top-sm text-Abc">{{ item.text }}</view>
					</view>
				</view>
			</view>
		</view>
 		<image class="footer-image" mode="widthFix" src="https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/2024/08/21/10188783-87433688-011.jpg"></image>
	</view>
</template>
<script>
	var vk = uni.vk;
	var _this;
	export default {
		data() {
			return {
				tavtext:[],
				TabCur: 0,
				scrollLeft: 0,
				userInfo:{},
				gridlist:[],
				// init请求返回的数据
				data:{
					
				},
				// 表单请求数据
				form1:{
					
				},
				scrollTop:0,
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		async onLoad(options = {}) {
			vk = uni.vk;
			_this = this;
			await this.getxxcjcxglobal()
			//await this.getxybxsf()
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady(){
			
		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		async onShow() {
			await this.getxxcjcxglobal()
			//_this.userInfo = vk.getVuex('$user.userInfo');
			//console.log(_this.userInfo)
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {
			
		},
		// 监听 - 点击右上角转发时
		onShareAppMessage(options) {
			
		},
		onTabItemTap(item) {
			this.dyxx()
		},
		// 函数
		methods: {
			dyxxbyxmt(){
				uni.requestSubscribeMessage({
				  tmplIds: ['FII6eFIVp7TYzIDchcREgsA9Nj9JffLL_4u6ZAgikyo'],
				  success (res) {
					  //console.log(res) 订阅新媒体打卡
				  },fail(fail){
					   //console.log(fail)
				  }
				})
			},
			getxybxsf(){
				return vk.callFunction({
					url: 'client/gsxy/xybx/pub/xybxapi.getGsxyxybxsjobjList',
					data: {}
				}).then((data) => {
					this.xywxsf = data.list
				}).catch((err) => {});
			},
			getxxcjcxglobal(){
				return vk.callFunction({
				  url: 'client/gsxy/globalDataCacheKye/kh/vk-global-data.findById',
				  data:{
				    _id:'65a61f1521821b50aff3eef4'
				  }
				}).then((data) => {
					this.tavtext = data.info.filter(grid => grid.xwzt == 99);
					this.gridlist = data.info.filter(grid => grid.showzt == '1');
				}).catch((err) => {
				  
				});
			},
			dyxx(){
				return uni.requestSubscribeMessage({
				  tmplIds: ['21CX0MkjAUc8VMZgi9xlxEiVDLlNZ-Z4KJ_Nfu9ScqA'],
				  success (res) {
				  },fail(fail){}
				})
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
			},
			link(item){
				if(item.text == '员工通道'){
					//console.log('员工通道')
					vk.navigateTo('/pages_modules/bdsj/gsxyygtd');
				}else if(item.text == '学籍查询'){
					vk.navigateTo('/pages_bd/gsxgj/student_status_enquiry');
				}else if(item.text == '毕业证查询'){
					vk.navigateTo('/pages_bd/gsxgj/diploma');
				}else if(item.text == '新生报到'){
					vk.navigateTo('/pages_bd/gsxgj/tzxsdl');
				}else if(item.text == '计算机等级考试'){
					vk.navigateTo('/pages_bd/gsxgj/computer_level_query');
				}else if(item.text == '英语三级考试查询'){
					vk.navigateTo('/pages_bd/gsxgj/yysjcx');
				}else if(item.text == '录取查询'){
					vk.navigateTo('/pages_bd/gsxgj/xueshenglvqutongzhi');
				}else if(item.text == '新媒体考核（教职工）'){
					_this.userInfo = vk.getVuex('$user.userInfo');
					if(_this.userInfo.ooppid){
						
					}else{
						uni.login({
							"provider": "weixin",
							"onlyAuthorize": true, // 微信登录仅请求授权认证
							success: async function(event){
								const {code} = event
								//客户端成功获取授权临时票据（code）,向业务服务器发起登录请求。
								await vk.callFunction({
								  url: 'client/gsxy/xmtdk/pub/xmtdkapi.getxmtopid',
								  title:'请求中...',
								  data:{
								    code:code
								  }
								}).then((data) => {
								  vk.setVuex('$user.userInfo.ooppid',data.code2SessionRes.openid);
								}).catch((err) => {
								  
								});
							},
							fail: function (err) {
						        // 登录授权失败
						        // err.code是错误码
						    }
						})
					}
					if(_this.userInfo.xmtdk&& _this.userInfo.xmtdk == '1'){
						vk.navigateTo('/pages_bd/dlyemian/xmtdklist');
					}else{
						vk.navigateTo('/pages_bd/dlyemian/xmtdk');
					}
				}else if(item.text == '新媒体考核'){
					this.dyxxbyxmt();
					vk.navigateTo('/pages_bd/xmt_xs/xmt_xs_dl');
				}else if(item.text == '缴费通道'){
					vk.navigateTo('/pages_bd/gsxgj/dzsxdl');
				}else if(item.text == '后勤报修'){
					uni.login({
						"provider": "weixin",
						"onlyAuthorize": true, // 微信登录仅请求授权认证
						success: async function(event){
							const {code} = event
							//客户端成功获取授权临时票据（code）,向业务服务器发起登录请求。
							await vk.callFunction({
							  url: 'client/gsxy/xmtdk/pub/xmtdkapi.getxmtopid',
							  title:'请求中...',
							  data:{code:code}
							}).then((data) => {
							  vk.setVuex('$user.userInfo.wx_openid.mp-weixin',data.code2SessionRes.openid);
							}).catch((err) => {});
						},
						fail: function (err) {}
					})
					vk.navigateTo('/pages_bd/xybx/xybxsy');
				}else if(item.text == '成教缴费'){
					vk.navigateTo('/pages_bd/gsxgj/crjydl');
				}else if(item.text == '学院考试'){
					vk.navigateTo('/pages_bd/wszl/ksjmxz');
				}else if(item.text == '刷题科目'){
					vk.navigateTo('/pages_bd/stgl/stgl');
				}else if(item.text == '视频投票'){
					vk.navigateTo('/pages_bd/jmtp/jptp-list');
				}else if(item.text == '成绩查询'){
					vk.navigateTo('/pages_modules/jwc/grades');
				}else if(item.text == '考勤查询'){
					vk.navigateTo('/pages_modules/jwc/kqlistlogin');
				}else if(item.text == '教务'){
					vk.navigateTo('/pages_modules/jwc/gsxy-jw');
				}else if(item.text == '讲课评审'){
					vk.navigateTo('/pages_bd/jmtp/xmt_xs_dl');
				}else if(item.text == '监督服务'){
					vk.navigateTo('/pages_modules/fwjdpt/fwjdpt');
				}else if(item.text == '老生缴费'){
					vk.navigateTo('/pages_modules/bdsj/qtjfdl');
					//vk.navigateTo('/pages_modules/bdsj/ceshibjs');
				}
			}
		},
		// 监听器
		watch:{
			
		},
		// 计算属性
		computed:{
			
		}
	}
</script>
<style lang="scss" scoped>
	.text-orange, .line-orange, .lines-orange {
	    color: #297849;
	}
	.imageIon {
		width: 95upx;
		height: 95upx;
	}
	.vvv{
		font-size: 14px;
		line-height: 3.0;
	}
  .footer-image {  
		height: auto;
		position: fixed;
		bottom: 0;
		width: 100%;
  }
</style>